#include "LinkQueue.h"
#include <stdio.h>
#include <stdlib.h>

#define true 1
#define false 0

int InitLQueue(LQueue *lq)
{
   
    return InitDLList(&lq->queue);
}

void QPush(LQueue *lq, ElementType element)
{
    InsertTail(&lq->queue,element);
}

ElementType* QPop(LQueue *lq)
{
    if(lq->queue.len == 0)
    {
        printf("the queue is empty!\n");
        return NULL ;
    }
    
    lq->frontData = lq->queue.head->data ;

    RemoveByIndex(&lq->queue,0);

    return &lq->frontData;
}

struct Node *GetFront(LQueue *lq)
{
    return lq->queue.head;
}

int GetQueueLen(LQueue *q)
{
    return q->queue.len;
}

int IsQEmpty(LQueue *lq)
{
    if(lq->queue.len == 0)
    {
        return true;
    }
    else
    {
        return false;
    }
}

void FreeLQueue(LQueue *lq, void (*p)(ElementType))
{
    FreeDLinkLIst(&lq->queue,p);
    free(lq);
    lq = NULL ;
}

